package com.c3p0;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.sql.*;

public class C3p0Utils {


    public static Connection getCon() throws SQLException {


        return new ComboPooledDataSource().getConnection();
    }


    /*释放资源的方法*/
    public static void close(ResultSet rs, Statement stat, Connection con) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }

        if (stat != null) {
            try {
                stat.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }

        if (con != null) {
            try {
                con.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
}
